<?php
namespace app\index\controller;

class QqLogin extends Common
{
    public function login()
    {
        $data = input('get.do');
		if(!input('area'))return array('saveOK'=>-1,'msg'=>'请选择服务器');
		if(config('sys_is_qqlogin_api_check_'.input('area'))==NULL){
			return array('saveOK' => -1, 'msg' => '登陆服务器不存在');
		}elseif(config('sys_is_qqlogin_api_check_'.input('area'))==0){
			return array('saveOK' => -1, 'msg' => '登陆服务器未开启');
		}else{
			$api = config('sys_is_qqlogin_api_url_'.input('area'));
			switch ($data) {
				case 'checkvc':
					$data=[
						'uin'	=>	input('post.uin'),
						'tokenid'	=>	input('post.tokenid')
					];
					$send=send_get($api.'?do=checkvc',$data);
					$result=json_decode($send);
					break;
				case 'dovc':
					$data=[
						'uin'	=>	input('post.uin'),
						'sig'	=>	input('post.sig'),
						'ans'	=>	input('post.ans'),
						'cap_cd'	=>	input('post.cap_cd'),
						'sess'	=>	input('post.sess'),
						'collectname'	=>	input('post.collectname'),
						'websig'	=>	input('post.websig'),
						'cdata'	=>	input('post.cdata'),
						'sid'	=>	input('post.sid')
					];
					$send=send_get($api.'?do=dovc',$data);
					$result=json_decode($send);
					break;
				case 'getvc':
					$data=[
						'uin'	=>	input('post.uin'),
						'sig'	=>	input('post.sig'),
						'sess'	=>	input('post.sess'),
						'sid'	=>	input('post.sid'),
						'websig'	=>	input('post.websig')
					];
					$send=send_get($api.'?do=getvc',$data);
					$result=json_decode($send);
					break;
				case 'qqlogin':
					$api = config('sys_is_qqlogin_api_url_'.input('post.area'));
					$data=[
						'uin'	=>	input('post.uin'),
						'pwd'	=>	input('post.pwd'),
						'p'	=>	input('post.p'),
						'vcode'	=>	input('post.vcode'),
						'pt_verifysession'	=>	input('post.pt_verifysession'),
						'cookie'	=>	input('post.cookie')
					];
					$send=send_get($api.'?do=qqlogin',$data);
					$result=json_decode($send);
					break;
				case 'getqrpic':
					$data=[
					];
					$send=send_get($api.'?do=getqrpic',$data);
					$result=json_decode($send);
					break;
				case 'qrlogin':
					$data=[
						'qrsig'	=>	input('qrsig')
					];
					$send=send_get($api.'?do=qrlogin',$data);
					$result=json_decode($send);
					break;
				case 'getvcpic':
					header('content-type:image/jpeg');
					$send=send_get($api.'?do=qrlogin?uin='.input('get.uin').'&sig='.input('get.sig').'&cap_cd='.input('get.cap_cd').'&sess='.input('get.sess').'&sid='.input('sid').'');
					echo $send;
					break;
			}
		}
        return $result;
    }
}